"""
利用Python进行数据分析

读写文本格式的数据

pandas
"""
from pandas import Series, DataFrame
import pandas as pd


def read_test_01():
    """
    读取文件部分数据
    或
    逐块读取文本文件
    :return:
    """
    # names = ['年龄', '性别', '地区', '金额', '周期', '类型', '状态']
    # result = pd.read_csv('ex6.csv', names=names, header=None)
    # print(result)

    # result = pd.read_csv('ex6.csv', header=None, nrows=5)
    # print(result)

    chunker = pd.read_csv('ex6.csv', header=None, chunksize=1)
    # print(chunker)
    tot = Series([])
    for piece in chunker:
        print(piece)
        print('-------------------------------------')
        tot = tot.add(piece[0].value_counts(), fill_value=0)

    print('--------------------tot-----------------')
    print(tot)


def main():
    read_test_01()


if __name__ == '__main__':
    main()
